﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using famails.iface;
using famails.dao;
using famails.App_Code.source.dto;
namespace famails.bus
{
    /// <summary>
    /// Summary description for ProductBUS
    /// </summary>
    public class CM_ProductBUS : ICM_Product
    {
        CM_ProductDAO cateDao;
        public CM_ProductBUS()
        {
            cateDao = new CM_ProductDAO();
        }

        #region IProduct Members

        public DataTable GetByID(decimal ID,int userID)
        {
            return cateDao.GetByID(ID, userID);
        }

        #endregion


        public DataTable Search(string Name, string Code,int userID)
        {
            return cateDao.Search(Code, Name, userID);
        }
        public DataTable Search(string Name, string Code, int groupid, string from, string to, decimal pfrom, decimal pto, int userID)
        {
            return cateDao.Search(Name, Code, groupid, from, to, pfrom, pto, userID);
        }
        public DataTable GetAll(int userID)
        {
            return cateDao.GetAll(userID);
        }

        public object Insert(CM_ProductDTO dto)
        {
            return cateDao.Insert(dto);
        }

        public bool Edit(CM_ProductDTO dto)
        {
            return cateDao.Edit(dto);
        }

        public bool Delete(int id)
        {
            return cateDao.Delete(id);
        }

        public bool CheckExistsName(string name, int id)
        {
            return cateDao.CheckExistsName(name, id);
        }

        public bool CheckBeforeDelete(int id)
        {
            return cateDao.CheckBeforeDelete(id);
        }

        internal DataTable GetByCode(string code, int id)
        {
            return cateDao.GetByCode(code, id);
        }

        internal bool CheckExistsCode(string code, decimal id, int userid)
        {
            return cateDao.CheckExistsCode(code, id, userid);
        }

    }
}